package cn.org.intelli.zjgflink.domain;

public class BackBean<T> {
    private boolean status;
    private T data;
    private Long totalNum;
    private String message;
    private String exception;
    private String exceptionMessage;

    // 私有构造方法
    private BackBean(boolean status, T data, Long totalNum, String message,
                     String exception, String exceptionMessage) {
        this.status = status;
        this.data = data;
        this.totalNum = totalNum;
        this.message = message;
        this.exception = exception;
        this.exceptionMessage = exceptionMessage;
    }

    // 静态 builder() 方法 - 修复泛型问题
    public static <T> BackBeanBuilder<T> builder() {
        return new BackBeanBuilder<>();
    }

    // 便捷静态方法
    public static <T> BackBean<T> success(T data) {
        return BackBean.<T>builder()
                .status(true)
                .data(data)
                .message("操作成功")
                .build();
    }

    public static <T> BackBean<T> success(T data, String message) {
        return BackBean.<T>builder()
                .status(true)
                .data(data)
                .message(message)
                .build();
    }

    // 原有的 getter 和 setter 方法...
    public boolean isStatus() {
        return status;
    }

    public void setStatus(boolean status) {
        this.status = status;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public Long getTotalNum() {
        return totalNum;
    }

    public void setTotalNum(Long totalNum) {
        this.totalNum = totalNum;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getException() {
        return exception;
    }

    public void setException(String exception) {
        this.exception = exception;
    }

    public String getExceptionMessage() {
        return exceptionMessage;
    }

    public void setExceptionMessage(String exceptionMessage) {
        this.exceptionMessage = exceptionMessage;
    }

    // Builder 内部类
    public static class BackBeanBuilder<T> {
        private boolean status;
        private T data;
        private Long totalNum;
        private String message;
        private String exception;
        private String exceptionMessage;

        public BackBeanBuilder<T> status(boolean status) {
            this.status = status;
            return this;
        }

        public BackBeanBuilder<T> data(T data) {
            this.data = data;
            return this;
        }

        public BackBeanBuilder<T> totalNum(Long totalNum) {
            this.totalNum = totalNum;
            return this;
        }

        public BackBeanBuilder<T> message(String message) {
            this.message = message;
            return this;
        }

        public BackBeanBuilder<T> exception(String exception) {
            this.exception = exception;
            return this;
        }

        public BackBeanBuilder<T> exceptionMessage(String exceptionMessage) {
            this.exceptionMessage = exceptionMessage;
            return this;
        }

        public BackBean<T> build() {
            return new BackBean<>(status, data, totalNum, message, exception, exceptionMessage);
        }
    }
}